package componentgeneralizationcircle;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import componentgeneralizationcircle.ComponentGeneralizationCircleMatch;
import componentgeneralizationcircle.ComponentGeneralizationCircleMatcherFactory;
import componentgeneralizationcircle.ComponentGeneralizationCircleMatcher;

public class ComponentGeneralizationCircleConstraint extends Constraint<ComponentGeneralizationCircleMatch> {

	private ComponentGeneralizationCircleMatcherFactory matcherFactory;

	public ComponentGeneralizationCircleConstraint() {
		matcherFactory = new ComponentGeneralizationCircleMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "Component $component.name$ is involved in a generalization circle.";
	}

	@Override
	public EObject getLocationObject(ComponentGeneralizationCircleMatch signature) {
		Object location = signature.get("component");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<ComponentGeneralizationCircleMatch, ComponentGeneralizationCircleMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
